home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Development Platforms / CSMP Digests / csmp-v1-040.txt < prev    next >
Encoding:
Text File  |  1992-11-18  |  30.1 KB  |  829 lines  |  [TEXT/MPS ]

  1. C.S.M.P. Digest             Fri, 03 Apr 92       Volume 1 : Issue 40
  2.  
  3. Today's Topics:
  4.  
  5.     Absolutely the fastest animation possible?
  6.     Saving compressed 32-bit PICTs.
  7.     ?Changing In-Use File names (etc.)?
  8.     FPU instructions
  9.     Changing Fonts in Dialogs
  10.  
  11.  
  12. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  13.  
  14. These digests are available (by using FTP, account anonymous, your email
  15. address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
  16. edu.  This is also the home of the comp.sys.mac.programmer Frequently Asked
  17. Questions list.
  18.  
  19. These digests are also available via email.  Just send a note saying that you
  20. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  21. automatically receive each new digest as it is created.
  22.  
  23. The articles in these digests are taken directly from comp.sys.mac.programmer.
  24. They are not edited; all articles included in this digest are in their original
  25. posted form.  The only articles that are -not- included in these digests are
  26. those which didn't receive any replies (except those that give information
  27. rather than ask a question).  All replies to each article are concatenated
  28. onto the original article in the order in which they were received.  Article
  29. threads are not added to the digests until the last article added to the
  30. thread is at least one month old (this is to ensure that the thread is dead
  31. before adding it to the digests).
  32.  
  33. Send administrative mail to mkelly@cs.uoregon.edu.
  34.  
  35. -------------------------------------------------------
  36.  
  37. Subject: Absolutely the fastest animation possible?
  38. From: tony@tui.marcam.dsir.govt.nz (Tony Cooper)
  39. Date: Wed, 26 Feb 92 02:39:35 GMT
  40. Organization: Applied Mathematics Group D.S.I.R.
  41.  
  42.  
  43. What is the best way to display animation on the screen as fast as possible.
  44. Assuming a NUBUS video card I have some ideas:
  45.  
  46. 1) Turn off interrupts except the video card interrupt. Not sure how to do
  47. this but I'm sure it is easy.
  48.  
  49. 2) Copy images from RAM to the video card using one of
  50.     a) CopyBits
  51.     b) A single purpose version of CopyBits that is faster than Apple's
  52.     c) Address the NUBUS card directly (maybe block transfer is possible)
  53.     d) Some other method
  54.  
  55. 3) Store the images in RAM on the NUBUS card itself if available.
  56.  
  57. Does anyone have any better suggestions? Which is faster out of a) to d)?
  58. If c) is faster, how do you do it? It only has to work on my Mac. Ideally
  59. I'd like to do 67 frames per second and I want the pictures to be as big
  60. as possible. At least 512x512 pixels of 8 bit colour. (Now you know why I
  61. want it to be as fast as possible).
  62.  
  63. Thanks
  64. Tony Cooper
  65. tony@marcam.dsir.govt.nz
  66.  
  67.  
  68.  
  69. - -------------------------
  70.  
  71. From: rfischer@Xenon.Stanford.EDU (Ray Fischer)
  72. Subject:  Absolutely the fastest animation possible?
  73. Date: 26 Feb 92 09:12:57 GMT
  74. Organization: Computer Science Department, Stanford University.
  75.  
  76. tony@marcam.dsir.govt.nz writes ...
  77. >What is the best way to display animation on the screen as fast as possible.
  78. >
  79. >1) Turn off interrupts except the video card interrupt. Not sure how to do
  80. >this but I'm sure it is easy.
  81.  
  82. This may cause you problems.  Even if it doesn't, I'm not sure it would
  83. make a big difference. (couple percent?)
  84.  
  85. >2) Copy images from RAM to the video card using one of
  86. >    a) CopyBits
  87.  
  88. CopyBits will take care of alignment, but is fastest if both images are
  89. long word aligned and no color conversion gets done (i.e., both have
  90. the same color pallette)
  91.  
  92. >    b) A single purpose version of CopyBits that is faster than Apple's
  93. >    c) Address the NUBUS card directly (maybe block transfer is possible)
  94.  
  95. These two are likely to be the same solution.  Not a trivial undertaking.
  96.  
  97. >Does anyone have any better suggestions? Which is faster out of a) to d)?
  98. >If c) is faster, how do you do it? It only has to work on my Mac. Ideally
  99. >I'd like to do 67 frames per second and I want the pictures to be as big
  100. >as possible. At least 512x512 pixels of 8 bit colour. (Now you know why I
  101. >want it to be as fast as possible).
  102.  
  103. 512*512*67 works out to almost 17MB/sec.  For most Macs this is out
  104. of the question.  Considering that a IIcx has a clock rate of 16MHz
  105. and every instruction takes several clocks, it just doesn't work.
  106. This is one 32-bit word read or written every 115ns.  I don't know,
  107. but I doubt many Mac video cards or CPU's can provide this kind of
  108. performance.
  109.  
  110. The fastest way to get data onto the screen is find the address of the 
  111. screen buffer, then write an assembler routine to do block moves.  Loop
  112. unrolling is a must.  If you get this far, then you can get some idea
  113. of how fast you can transfer to the screen, and then decide where to 
  114. make the tradeoffs.
  115.  
  116. Ray
  117. rfischer@cs.stanford.edu
  118.  
  119.  
  120.  
  121. - -------------------------
  122.  
  123. From: lstein@athena.mit.edu (Lincoln Stein)
  124. Subject:  Absolutely the fastest animation possible?
  125. Date: 26 Feb 92 12:31:09 GMT
  126. Organization: Massachusetts Institute of Technology
  127.  
  128. >>Does anyone have any better suggestions? Which is faster out of a) to d)?
  129. >>If c) is faster, how do you do it? It only has to work on my Mac. Ideally
  130. >>I'd like to do 67 frames per second and I want the pictures to be as big
  131. >>as possible. At least 512x512 pixels of 8 bit colour. (Now you know why I
  132. >>want it to be as fast as possible).
  133. >
  134. >512*512*67 works out to almost 17MB/sec.  For most Macs this is out
  135. >of the question.  Considering that a IIcx has a clock rate of 16MHz
  136. >and every instruction takes several clocks, it just doesn't work.
  137. >This is one 32-bit word read or written every 115ns.  I don't know,
  138. >but I doubt many Mac video cards or CPU's can provide this kind of
  139. >performance.
  140.  
  141. NuBus on all machines up to the FX is limited to 10MB/sec (I think).  The
  142. Quadras can manage 20 MB/sec, but only on card-to-card transfers.  
  143. Motherboard-to-card is still limited to 10MB/sec due to a limitation of
  144. Apple's NuBus controller chip.  17MB/sec is too fast.
  145.  
  146. ==============================================================================
  147. Lincoln D. Stein            Brigham & Women's Hospital
  148. lstein@hstbme.mit.edu            Boston, MA
  149. ==============================================================================
  150.  
  151.  
  152.  
  153.  
  154. - -------------------------
  155.  
  156. From: suitti@ima.isc.com (Stephen Uitti)
  157. Subject:  Absolutely the fastest animation possible?
  158. Date: 26 Feb 92 19:54:46 GMT
  159. Organization: Interactive Systems, Cambridge, MA 02138-5302
  160.  
  161. >>512*512*67 works out to almost 17MB/sec.
  162.  
  163. >NuBus on all machines up to the FX is limited to 10MB/sec (I think).
  164.  
  165. If you can't do the whole job, do less.  So... if you have it all
  166. in memory to begin with, maybe you can compute just which pixels
  167. have changed in advance, and update only those.  Maybe extent
  168. lists, similar to run length encoding is the answer.  If it turns
  169. out that you only have to update half of the pixels, you may be
  170. able to increase the speed by enough.  Of course, it may take
  171. more than one frame to update the whole screen for a sudden
  172. screen change.
  173.  
  174. Stephen.
  175. suitti@ima.isc.com
  176.  
  177.  
  178.  
  179. - -------------------------
  180.  
  181. From: d88-jwa@hemul.nada.kth.se (Jon W{tte)
  182. Subject:  Absolutely the fastest animation possible?
  183. Date: 26 Feb 92 18:48:19 GMT
  184. Organization: Royal Institute of Technology, Stockholm, Sweden
  185.  
  186. > tony@tui.marcam.dsir.govt.nz (Tony Cooper) writes:
  187.  
  188.    1) Turn off interrupts except the video card interrupt. Not sure how to do
  189.    this but I'm sure it is easy.
  190.  
  191. What good would this do ? This is generally done on DOS machines,
  192. but is totally unacceptable on a mac, since the mouse will freeze
  193. and become jerky (and the keyboard is not heeded !)
  194.  
  195.    2) Copy images from RAM to the video card using one of
  196.        a) CopyBits
  197.  
  198. Yes ! This also works very well with accellerated cards. It
  199. is guaranteed to work with all future cards/systems/etc
  200.  
  201.        b) A single purpose version of CopyBits that is faster than Apple's
  202.  
  203. 1) It's hard to beat CopyBits if you know how to handle CopyBits
  204. right. Besides, try and make your CopyBits work with accelerated
  205. cards, 24bit cards on 24bit machines, various screen depths,
  206. windows spanning screens, ...
  207.  
  208.        c) Address the NUBUS card directly (maybe block transfer is possible)
  209.  
  210. No Block Transfers under program control.
  211.  
  212.    3) Store the images in RAM on the NUBUS card itself if available.
  213.  
  214. Only on accellerated cards. You do this by creating an offscreen
  215. GWorld (which will be on the card if the right flags are set)
  216. and draw your picture into that GWorld. Transfers within the card
  217. will be fast, but only for accellerated cards (won't matter much
  218. on other cards anyway...)
  219.  
  220.    as possible. At least 512x512 pixels of 8 bit colour. (Now you know why I
  221.    want it to be as fast as possible).
  222.  
  223. Keep dreaming. That's 256 kByte, 67 times/second > 17MB/second. Last
  224. I looked, Mac NuBus couldn't handle that, doing longword transfers,
  225. what with re-synching and everything.
  226.  
  227. Not to mention; where do you get those 17 MB of image data from ?
  228.  
  229. --
  230. This Signature is distributed under the conditions of the Signature License,
  231. available at a fee from   h+@nada.kth.se  (Jon W{tte)  Reading the Signature
  232. implies that you accept to be bound by the terms in said License. Should you
  233. not agree on any of these terms, you must return the Signature unread to me.
  234.  
  235.  
  236.  
  237. - -------------------------
  238.  
  239. From: unregistered@newcastle.ac.uk (R.W. Kentridge)
  240. Subject:  Absolutely the fastest animation possible?
  241. Date: 27 Feb 92 15:57:41 GMT
  242. Organization: Computing Laboratory, U of Newcastle upon Tyne, UK NE1 7RU.
  243.  
  244.  
  245.   512*512*67 = 17563648 or about 17.5 million byte moves per second.
  246.   Isn't a 680x0 going to have a bit of trouble with this?
  247.  
  248.   But you can still copy about twice as fast as CopyBits if you know
  249.   that your source and destination Rects are the same size and the 
  250.   same depth and if you ignore (or avoid) having any incomplete bytes
  251.   at Rect edges and then you do the copy loop in assembler (if the whole
  252.   rect can be moved with MOVE.Ls then this will be fastest) and you don't
  253.   support multiple screens and so on.  Still wont do 17.5 million bytes
  254.   a sec though :-(
  255.                     cheers,    
  256.                          bob
  257.  
  258.  
  259.  
  260. - -------------------------
  261.  
  262. From: jb@lexicon.com (Jim Bailey)
  263. Subject:  Absolutely the fastest animation possible?
  264. Organization: Lexicon, Inc., Waltham, MA
  265. Date: Thu, 27 Feb 1992 19:14:24 GMT
  266.  
  267. In article <1992Feb26.123109.14776@athena.mit.edu> lstein@athena.mit.edu (Lincoln Stein) writes:
  268.  
  269.    NuBus on all machines up to the FX is limited to 10MB/sec (I think).  The
  270.    Quadras can manage 20 MB/sec, but only on card-to-card transfers.  
  271.    Motherboard-to-card is still limited to 10MB/sec due to a limitation of
  272.    Apple's NuBus controller chip.  17MB/sec is too fast.
  273.  
  274.    ==============================================================================
  275.    Lincoln D. Stein            Brigham & Women's Hospital
  276.    lstein@hstbme.mit.edu            Boston, MA
  277.    ==============================================================================
  278.  
  279. The theoretical limit should be closer to 40MB/sec, ( 37 MB/sec I
  280. think ).  Are you saying that Apple's NuBus implementation is that
  281. limited?
  282.  
  283. Jim
  284. -- 
  285. "The Beatles were elevator music in my lifetime 'Yummy Yummy Yummy (I've Got
  286. Love In My Tummy)' had more impact on me" -- Michael Stipe of R.E.M.
  287. jb@lexicon.com
  288.  
  289.  
  290.  
  291. - -------------------------
  292.  
  293. From: ABSURD@applelink.apple.com (Tim Dierks, ToyMeister, Cray abuser)
  294. Subject:  Absolutely the fastest animation possible?
  295. Date: 2 Mar 92 21:27:06 GMT
  296. Organization: MacDTS, Apple Computer
  297.  
  298. In article <1992Feb26.123109.14776@athena.mit.edu>, lstein@athena.mit.edu (Lincoln Stein) writes:
  299. > >>Does anyone have any better suggestions? Which is faster out of a) to d)?
  300. > >>If c) is faster, how do you do it? It only has to work on my Mac. Ideally
  301. > >>I'd like to do 67 frames per second and I want the pictures to be as big
  302. > >>as possible. At least 512x512 pixels of 8 bit colour. (Now you know why I
  303. > >>want it to be as fast as possible).
  304. > >
  305. > >512*512*67 works out to almost 17MB/sec.  For most Macs this is out
  306. > >of the question.  Considering that a IIcx has a clock rate of 16MHz
  307. > >and every instruction takes several clocks, it just doesn't work.
  308. > >This is one 32-bit word read or written every 115ns.  I don't know,
  309. > >but I doubt many Mac video cards or CPU's can provide this kind of
  310. > >performance.
  311. > NuBus on all machines up to the FX is limited to 10MB/sec (I think).  The
  312. > Quadras can manage 20 MB/sec, but only on card-to-card transfers.  
  313. > Motherboard-to-card is still limited to 10MB/sec due to a limitation of
  314. > Apple's NuBus controller chip.  17MB/sec is too fast.
  315.  
  316. The NuBus runs at 10 MHz, which is 10 million cycles per second; however, up
  317. to four bytes can be transferred in each cycle, because the bus is 32 bits
  318. wide.  Because of arbitration cycles, etc, you don't get 100% throughput, so
  319. the maximum transfer speed is on the order of 37 megabytes/sec with tuned
  320. code.  However, this doesn't really happen on Macs, for the following reasons:
  321.  
  322.  - Video cards can't necessarily process a transaction in one cycle.
  323.  - Macs can't keep up that kind of transfer rate
  324.  - Because the NuBus runs at 10 MHz/sec, but Mac processors run at rates which
  325.    are not necessarily even divisors of that rate, the Mac often has to wait for
  326.    a moment to synchronize the data transfer.  This is a larger problem on
  327.    faster Macs, (the fx may have to wait up to 3 clock cycles to synchronize).
  328.  
  329. Best of luck,
  330. Tim Dierks
  331. MacDTS, but I speak for myself
  332.  
  333.  
  334.  
  335. ---------------------------
  336.  
  337. From: jesjones@milton.u.washington.edu (Jesse Jones)
  338. Subject: Saving compressed 32-bit PICTs.
  339. Organization: University of Washington, Seattle
  340. Date: Wed, 26 Feb 1992 22:11:31 GMT
  341.  
  342.  
  343.    I'm having some trouble saving a 24-bit image as a PICT. I'm trying
  344. to build the PICT without going through QuickDraw. When I use no packing
  345. everything works fine. However, when I use pack type 4 PhotoShop hangs
  346. when I try to open the PICT. I've compared my PICT file with one
  347. generated by PhotoShop and they look identical up to the pixData. I've
  348. also examined my code to pack the scan lines and am pretty sure it's
  349. OK.
  350.  
  351.    IM 6 is fairly terse but I think I understand how pack type 4 works:
  352. each component of a scan line is packed using PackBits. First red, then
  353. green, and finally blue. Each packed component is preceded by either a
  354. byte or a word for the byte count. This looks perfectly straightforward.
  355. Is there something I missed? Does IM leave anything out? Any help would
  356. be greatly appreciated.
  357.  
  358.   --Jesse
  359.  
  360.  
  361.  
  362.  
  363. - -------------------------
  364.  
  365. From: ralph@madras.anu.edu.au (Ralph Sutherland)
  366. Subject:  Saving compressed 32-bit PICTs.
  367. Organization: Computer Services Centre, Australian National University
  368. Date: Thu, 27 Feb 92 04:58:20 GMT
  369.  
  370.  
  371. jesjones@milton.u.washington.edu (Jesse Jones) wrote:
  372.  
  373.         .
  374.         .
  375.         .
  376.  
  377. >   IM 6 is fairly terse but I think I understand how pack type 4 works:
  378. >each component of a scan line is packed using PackBits. First red, then
  379. >green, and finally blue. Each packed component is preceded by either a
  380.  
  381. Did you forget the alpha channel or are only 24 of the 32 bits saved in 
  382. type 4 packing?
  383.  
  384. cheers
  385. ralph
  386.  
  387. -- 
  388. - -- Ralph S. Sutherland      Mount Stromlo & Siding Spring Observatories.
  389. - -- ralph@madras.anu.edu.au  The Australian National University.
  390. - -- rss100@cscgpo.anu.edu.au --------------------------------------------
  391.  
  392.  
  393.  
  394. - -------------------------
  395.  
  396. From: ABSURD@applelink.apple.com (Tim Dierks, ToyMeister, Cray abuser)
  397. Subject:  Saving compressed 32-bit PICTs.
  398. Date: 2 Mar 92 21:06:48 GMT
  399. Organization: MacDTS, Apple Computer
  400.  
  401. In article <1992Feb26.221131.15517@u.washington.edu>, jesjones@milton.u.washington.edu (Jesse Jones) writes:
  402. >    I'm having some trouble saving a 24-bit image as a PICT. I'm trying
  403. > to build the PICT without going through QuickDraw. When I use no packing
  404. > everything works fine. However, when I use pack type 4 PhotoShop hangs
  405. > when I try to open the PICT. I've compared my PICT file with one
  406. > generated by PhotoShop and they look identical up to the pixData. I've
  407. > also examined my code to pack the scan lines and am pretty sure it's
  408. > OK.
  409. >    IM 6 is fairly terse but I think I understand how pack type 4 works:
  410. > each component of a scan line is packed using PackBits. First red, then
  411. > green, and finally blue. Each packed component is preceded by either a
  412. > byte or a word for the byte count. This looks perfectly straightforward.
  413. > Is there something I missed? Does IM leave anything out? Any help would
  414. > be greatly appreciated.
  415.  
  416. Actually, there's only one byte count, which counts the bytes for all three
  417. components.  This isn't incredibly obvious by the description, but can be
  418. seen in the format description (in Courier, near the top of page IV-17-22).
  419.  
  420. If packType > 2 (packed) then
  421. ..
  422.     Each scan line consists of [byteCount] [data].
  423.  
  424. Implying that byte counts are line-based, not component-based.  I build an
  425. array with all three components, packed together, then PackBits the whole
  426. thing, then write the count, then the entire packed array.
  427.  
  428. Tim Dierks
  429. MacDTS, but I speak for myself
  430.  
  431.  
  432.  
  433. ---------------------------
  434.  
  435. From: Bill Williams
  436. Subject: ?Changing In-Use File names (etc.)?
  437. Date: 27 Feb 92 18:13:26 GMT
  438.  
  439. Netters,
  440.  
  441.      I have written a lab data collection/automation program that writes data  
  442. periodically to a file.  The technician in my lab noted the other night that a  
  443. file that the program was writing to didn't follow our lab naming/folder  
  444. conventions, so she got into the finder (system 7), moved the file into the  
  445. proper folder, and renamed it!  But the file was still in use!!!
  446.  
  447.     Questions:
  448.  
  449.     1.  Shouldn't the fact that the file is in use be discovered by the  
  450. Finder and disallowed??!!??
  451.  
  452.     2.  What kinds of trouble can be caused by renaming a file while it's  
  453. in use?  It seems like it could cause all kinds of problems; in my program, for  
  454. example, the name of the file is displayed (dimmed) in the File menu replacing  
  455. the "open" item, so the user can figure out what's going on.
  456.  
  457.     3.  Is there some way for my program to "lock" the filename, so that  
  458. the Finder won't allow it to be moved or changed?
  459.  
  460.  
  461.             -Bill Williams
  462.             -St. Mary's College of Maryland
  463.  
  464.  
  465.  
  466. - -------------------------
  467.  
  468. From: jcav@quads.uchicago.edu (JohnC)
  469. Subject:  ?Changing In-Use File names (etc.)?
  470. Date: 27 Feb 92 18:54:36 GMT
  471. Organization: The Royal Society for Putting Things on Top of Other Things
  472.  
  473. In article <11533@umd5.umd.edu> Bill Williams writes:
  474. >     I have written a lab data collection/automation program that writes data  
  475. >periodically to a file.  The technician in my lab noted the other night that
  476. >a file that the program was writing to didn't follow our lab naming/folder  
  477. >conventions, so she got into the finder (system 7), moved the file into the  
  478. >proper folder, and renamed it!  But the file was still in use!!!
  479. >
  480. >    Questions:
  481. >
  482. >    1.  Shouldn't the fact that the file is in use be discovered by the  
  483. >Finder and disallowed??!!??
  484.  
  485. Why?  This is the documented behavior of _Rename.  While a file is open, it
  486. is referred to by a path reference number, not by name, so this really
  487. shouldn't cause any problems.
  488.  
  489. >    2.  What kinds of trouble can be caused by renaming a file while it's  
  490. >in use?  It seems like it could cause all kinds of problems; in my program,
  491. >for example, the name of the file is displayed (dimmed) in the File menu
  492. >replacing the "open" item, so the user can figure out what's going on.
  493.  
  494. You should modify your program to check the name periodically, in order to
  495. update the menu item if the file name has changed.
  496.  
  497. >    3.  Is there some way for my program to "lock" the filename, so that  
  498. >the Finder won't allow it to be moved or changed?
  499.  
  500. I don't believe this is possible on non-shared volumes, although on shared
  501. volumes there is a check-box to prevent the object (file or folder) from
  502. being moved or renamed.
  503.  
  504.  
  505. -- 
  506. John Cavallino                  |  EMail: jcav@midway.uchicago.edu
  507. University of Chicago Hospitals |         John_Cavallino@uchfm.bsd.uchicago.edu
  508. Office of Facilities Management | USMail: 5841 S. Maryland Ave, MC 0953
  509. B0 f++ c+ g+ k s+(+) e+ h- pv   |         Chicago, IL  60637
  510.  
  511.  
  512.  
  513. - -------------------------
  514.  
  515. From: Michael_Hecht@mac.sas.com (Michael Hecht)
  516. Subject:  ?Changing In-Use File names (etc.)?
  517. Date: 2 Mar 92 15:54:27 GMT
  518. Organization: SAS Institute Inc.
  519.  
  520. In article <11533@umd5.umd.edu>, Bill Williams writes:
  521. >     3.  Is there some way for my program to "lock" the filename, so that  
  522. > the Finder won't allow it to be moved or changed?
  523.  
  524. You can call SetFLock on the file to lock it while you're writing to it.
  525. This won't prevent it from being changed, but it will slow the user down
  526. if they try to open it, for example. Before you close it, call RstFLock.
  527.  
  528. You can prevent the file from being renamed by setting its System bit.
  529.  
  530. You could also intially name the file some thing like "Whatever (in use)"
  531. while you're writing to it. Then, rename it to the correct name after you
  532. close it.
  533.  
  534. You could also make the file invisible while you have it open.
  535.  
  536. --Michael
  537.  
  538. PS: Nice return address :-)
  539.  
  540. =======================================================================
  541. Michael P. Hecht                 | Internet:  Michael_Hecht@mac.sas.com
  542. SAS Institute Inc.; Cary, NC USA | AppleLink: SAS.HECHT
  543.  
  544.  
  545.  
  546. ---------------------------
  547.  
  548. From: mhall@occs.cs.oberlin.edu (Matthew Hall)
  549. Subject: FPU instructions
  550. Date: 28 Feb 92 02:07:26 GMT
  551. Organization: Oberlin College Computer Science
  552.  
  553. Hello - 
  554.     I am trying to write a unit that will read a typed in string
  555. of a mathematical function - translate it into RPN, and (here's the
  556. tricky part) Compile it into FPU code.  That is, at runtime, create a subroutine in
  557. the heap that when I  (JSR (funcptr)) it pops the return value into my
  558. stack.  
  559.     Okay, everything is easy so far.  I got the RPN, I got the
  560. subroutine to move the data to return nicely with a number on the
  561. stack.  The problem is - I'm not sure of the FPU instructions.  By
  562. poking around with macsbug, I figured that an FPU opcode looks
  563. something like this
  564.  
  565.   bits 24 - 31  Always F2
  566.   bits 22 - 23  ?
  567.   bits 16 - 21  Addressing mode and reggister for CPU addressing
  568.   bits 13 - 15  000 for addressing FPU regs
  569.         010 for CPU reg as source
  570.         011 for CPU register as destination
  571.   bits 10 - 12  Destination FPU reg, or size of data for CPU reg
  572.           operations (What is .P the size of?)
  573.   bits 7  - 9   Another FPU reg
  574.   bits 0  - 6   The Instruction (00 - move,  23 - multiply I guess)
  575.  
  576. Now, I don't have access to any FPU manuals.  I think I have the right
  577. idea - I just want to be sure that I have this right before I start
  578. programming a mini assembler (I only have THINK Pascal, so writing
  579. this will be a bit tricky)  Plus, there are some missing bits.  Could
  580. some kind generous soul with a 68881/2 manual pleas help me.
  581.  
  582. (Oh yeah, what's the difference between a 68881 and an '82.  Always
  583. been curious)
  584.  
  585. Thanks - 
  586. matt hall
  587.  
  588. Alt. Mail address - SMH9666@OBERLIN.bitnet
  589.  
  590.  
  591. --
  592.  
  593. <<mhall@occs.edu OR
  594. <<SMH9666@OBERLIN.BITNET
  595.  
  596. This is just a beta version signature
  597.  
  598.  
  599.  
  600. - -------------------------
  601.  
  602. From: orpheus@reed.edu (P. Hawthorne)
  603. Subject:  FPU instructions
  604. Date: 29 Feb 92 09:55:03 GMT
  605. Organization: Reed College, Portland OR
  606.  
  607.  
  608.   mhall@occs.cs.oberlin.edu (Matthew Hall) writes:
  609. : I am trying to write a unit that will read a typed in string of
  610. : a mathematical function - translate it into RPN, and (here's the
  611. : tricky part) Compile it into FPU code.
  612.  
  613.   If you want concurrent execution, you need the timing in the Motorola
  614. manuals, but as far as simple operations, you can basically have a go at
  615. the instruction formats in ResEdit with the CODE resource editor from
  616. ftp.apple.com and get simple arithmetic functions. That's how I've learned.
  617. Big hint, any similarity from instruction to instruction is pure luck, and
  618. the bits you don't know about can hurt you. Rounding mode is subtle.
  619.   Getting the addressing modes right is the worst part, after assembling
  620. the branches and jumps. There's a fast trick for FPU divide by two.
  621.   In a perfect world, you would get the manuals. I borrowed mine from a
  622. friend, and found myself much, much more expressive. Get in touch with me
  623. and I'll fax you some instruction formats, if you're interested. I'm
  624. interested in how you handled operator precedence in postfix translation,
  625. since I'm just using a 2D array.
  626.  
  627.   There are eight 80-bit extended precision registers, but Think Pascal
  628. uses all of them. FP0, FP1, and FP2 are not relied upon by Think Pascal to
  629. hold values between Pascal terms, so they're basically available. From
  630. interrupts, all bets are off as to what condition the registers are in. All
  631. of the addressing modes are there, but they are done by the 680n0.
  632.   All operations are performed at extended precision even if conversion is
  633. required, which basically means use native extended precision if you're a
  634. speed freak, and it sounds like you are. I know I am. ;-}
  635.   If you're really hell bent on end run performance, you can interleave
  636. fixed point and FPU instructions so that you get both processors going at
  637. once. I did this with for an adaptive Bezier curve subdivision routine,
  638. which consumed half of the application run time, and got an improvement in
  639. response time. Sure it took me forever, but it is a strong performance
  640. factor for machines blessed with 6888n FPUs.
  641.   Crying shame that the Quadras are lobotomized in this respect.
  642.  
  643.  "Good news: we've got TV bandwidth and are moving to consumer electronics,
  644.   the bad: we left out transcendentals and are going RISC. Get over it."
  645.                           -- Apple Computer, Inc. 1992
  646.   Theus orpheus@reed.edu (503) 230-1242
  647.  
  648.  
  649.  
  650.  
  651. - -------------------------
  652.  
  653. From: rfischer@Xenon.Stanford.EDU (Ray Fischer)
  654. Subject:  FPU instructions
  655. Organization: Computer Science Department, Stanford University.
  656. Date: Sun, 1 Mar 1992 22:35:54 GMT
  657.  
  658. mhall@occs.cs.oberlin.edu (Matthew Hall) writes ...
  659. >    Okay, everything is easy so far.  I got the RPN, I got the
  660. >subroutine to move the data to return nicely with a number on the
  661. >stack.  The problem is - I'm not sure of the FPU instructions.  By
  662. >poking around with macsbug, I figured that an FPU opcode looks
  663. >something like this
  664. >
  665. >  bits 24 - 31  Always F2
  666. >  bits 22 - 23  zero
  667. >  bits 16 - 21  Addressing mode and reggister for CPU addressing
  668.    bit  15       zero
  669. >  bits 14       register(0) or memory(1) for source operand
  670.    bit  13       zero usually, 1 for FMOVE from FPn
  671. >  bits 10 - 12  Source specifier (expect for FMOVE from FPn,
  672.         then dest format)
  673. >  bits 7  - 9   dest reg, except FMOVE from FPn, then source reg
  674. >  bits 0  - 6   The Instruction (00 - move,  23 - multiply I guess)
  675.         Correct, except k-factor with FMOVE from FPn which
  676.         involves packed decimal formats
  677. >
  678. >Now, I don't have access to any FPU manuals.  I think I have the right
  679.  
  680. Get one.  The 68882 is complex with options for handling various
  681. number formats and exception conditions, in addition to several
  682. instructions.  Prentice Hall ISBN 0-13-567009-8
  683.  
  684. >(Oh yeah, what's the difference between a 68881 and an '82.  Always
  685. >been curious)
  686.  
  687. The 68882 has the capability of doing transfers to/from memory while
  688. the APU is doing computation.  Thus, the 68882 can load one register
  689. while doing math with a different register.  The 68881, in general,
  690. can't do this.
  691.  
  692. Ray
  693. rfischer@cs.stanford.edu
  694.  
  695.  
  696.  
  697. ---------------------------
  698.  
  699. Subject: Changing Fonts in Dialogs
  700. From: djvelleman@amherst.edu
  701. Date: 26 Feb 92 15:46:02 GMT
  702. Organization: Amherst College, Amherst, MA.
  703.  
  704.   I'm writing an application which has to use some funny symbols in dialog
  705. boxes.  I have implemented this by creating my own font, and then calling
  706. SetDAFont to have my font used in the dialog boxes.  The problem with this
  707. is that my font gets used in other dialog boxes too--for example, sometimes
  708. if a desk accessory is opened while my program is running, it ends up using
  709. my font.
  710.   I can think of a number of ways to avoid this problem, but I'm wondering
  711. if there is a "recommended" way of doing it.  Should I call SetDAFont right
  712. before I create a dialog, and then call it again as soon as I'm done with
  713. the dialog to set the DA Font back to the system font?  Can I even change
  714. the DA Font back to the system font once I have created the dialog (but
  715. before I'm done with it)?  (In other words, is the DA Font only looked at
  716. by GetNewDialog?)  Should I forget about SetDAFont altogether and
  717. just create the dialog record and then change its font before I show it?
  718. (If so, do I change the txFont field of the dialog's grafport, or its
  719. TextEdit record, or both?  My guess is that the txFont field of the grafport
  720. will affect static text items and the TextEdit record will affect edit text
  721. items, but I haven't tried it.  Can I even make these two different if I want
  722. to?)
  723.   Please e-mail responses, since I don't read this newsgroup regularly.
  724. Thanks.
  725.   Dan Velleman
  726.   Dept. of Math & CS
  727.   Amherst College
  728.   djvelleman@amherst.edu
  729.  
  730.  
  731.  
  732.  
  733. ---------------------------
  734.  
  735. From: bitting-douglas@CS.YALE.EDU (Douglas Bitting)
  736. Subject: A5 and Completion Routines
  737. Organization: You gotta be kidding me!
  738. Date: Sat, 29 Feb 1992 21:29:31 GMT
  739.  
  740.  
  741. Hi.  I am having trouble setting up A5 for use within a completion
  742. routine.  I have been pulling my hair out over this for the last 4
  743. hours (I don't give up easily, do I?).  Instead of me trying to
  744. explain everything to you, I'll show you the code (it's reasonably
  745. short) that is bothering me:
  746.  
  747. - --snip here----
  748. static    short    done;
  749.  
  750. // As per TechNote #180
  751. MPPPBPtr
  752. GetMPPPBPtr(void)
  753.     = 0x2008;                // MOVE.L    A0,D0
  754.  
  755. // Again, follows closely from TN#180
  756. pascal void
  757. SetDone(void)
  758. {
  759.     long        tmpA5;
  760.     MPPPBPtr    whee;
  761.     MPPParamBlock    mp;
  762.     
  763.     whee = GetMPPPBPtr();
  764.     mp = *whee;
  765.  
  766.     tmpA5 = SetA5(mp.NBP.userData);
  767.     done = 1;            // to flag PLookup() is done
  768.     SetA5(tmpA5);
  769. }
  770.  
  771. void
  772. FindMe (char *what, char *name)
  773. {
  774.     [...]
  775.     
  776.     mp.NBP.ioCompletion = SetDone;
  777.     mp.NBP.interval = 1;
  778.     mp.NBP.count = 4;
  779.     mp.NBP.userData = SetCurrentA5();
  780.  
  781.     [...Don't worry, I set up the rest of mp...]
  782.     
  783.     if (CheckError(PLookupName(&mp, true))) {
  784.  
  785.     [...]
  786.     
  787.     while (!done) {
  788.         WaitNextEvent(everyEvent, &blah, 5L, aRgn); // sleep
  789.     }
  790.     
  791.     done = 0;
  792.     
  793.     [...]    
  794. }
  795. - --snip here----
  796.  
  797. I checked with MacsBug and it is definitely getting to the completion
  798. routine, but the value that is found in mp.NBP.userData is not even
  799. close to what A5 should be set to.  So, one question would be "Does
  800. mp.NBP.userData get clobbered by PLookupName()?" ... the next would if
  801. "If not, then what the heck am I doing wrong?"
  802.  
  803. Thanks!
  804. --Doug
  805. --
  806.  ...Doug Bitting... || "But the wisdom that comes from heaven is first
  807.                     ||  of all pure; then peace loving, considerate,
  808. bitting@cs.yale.edu ||  submissive, full of mercy, and good fruit,
  809. doug@yalevm.bitnet  ||  impartial and sincere."  -- James 3:17
  810. -- 
  811. --
  812. A crisis is when you can't say Let's forget the whole thing.
  813.  
  814.  
  815.  
  816. - -------------------------
  817.  
  818. From: orpheus@reed.edu (P. Hawthorne)
  819. Subject:  A5 and Completion Routines
  820. Date: 1 Mar 92 12:07:08 GMT
  821. Organization: Reed College, Portland OR
  822.  
  823.  
  824.   bitting-douglas@CS.YALE.EDU (Doug